<?php
namespace Admin\Controller;
//use Think\Controller; //命名空间
use Tools\AdminController;
class IndexController extends AdminController {
	
    public function head(){
    	$this->display();
    }
	public function left(){
		//根据管理员获得其角色，进而获得角色权限
		//根据管理员id信息获得其本身记录信息
		$admin_id = session('admin_id');
		$admin_name = session('admin_name');

		$manager_info = D('Manager')->find($admin_id);
		$role_id = $manager_info['mg_role_id'];

		//2.根据$role_id获得本身记录信息
		$role_info = D('Role')->find($role_id);
		$auth_ids = $role_info['role_auth_ids'];

		//3.根据$auth_ids 获得具体权限
		//admin超级管理员没有权限限制 $admin_name === 'admin'
		if($role_id === '0'){ //超级管理员id = 0
			$auth_infoA = D('Auth')->where("auth_level=0")->select();
			$auth_infoB = D('Auth')->where("auth_level=1")->select();
		}else{
		//父集
		$auth_infoA = D('Auth')->where("auth_level=0 and auth_id in($auth_ids)")->select();
		//子集
		$auth_infoB = D('Auth')->where("auth_level=1 and auth_id in($auth_ids)")->select();
		}

		$this->assign('auth_infoA',$auth_infoA);
		$this->assign('auth_infoB',$auth_infoB);

    	$this->display();
    }
	public function right(){
    	$this->display();
    }
	public function index(){
    	$this->display();
    }
}